PDF and Music - 2

Not all music are in PDF format. More music are in image formats such JPG, PNG, or TIFF. For example, the following resource Pinterest provides  music sheets for marches, waltzes, rags, theater music, cornet solos, trombone features, and much more in the PNG format mostly. And if you want to convert music sheets in the image format, you can use PDF Mosaic SDK .NET for your purposes. PDF Mosaic .NET Library has able to convert images in various formats (bmp, jpeg, png, tiff, gif) to PDF documents. You can create an image from a file in GIF/TIFF/PNG/BMP/JPEG formats, or a buffer of image bytes, or an System.Drawing.Image object. To create PDF files from images, use PDFImage object and the following methods of canvas: public void DrawImage(PDFMosaic.PDFImage image,System.Single left,System.Single top), public void DrawImage(PDFMosaic.PDFImage image, System.Single left, System.Single top, System.Singlewidth, System.Single height).

The below is code for creating PDF from images

using PDFMosaic;
using System.Drawing;

namespace DrawImage
{
    class DrawImage
    {
        static void Main()
        {
            PDFDocument document = new PDFDocument();
            document.Pages.Add(new PDFPage(PDFPaperFormat.A4));
            PDFCanvas canvas = document.Pages[0].Canvas;
            PDFImage image = new PDFImage("musicsheet.jpg");            
            canvas.DrawImage(image, 0, 0, image.Width, image.Height);
            document.Save("music.pdf", true);
        }
    }
}

 

Please see the sample PDF music compilations here: music.pdf

The PDF file was created by PDF Mosaic .NET Library. Original image here.
As can you see, creation of PDF is easy process with help of PDF SDK for .NET. Try it!

Read the first part of the article.

 

Team of PDF Mosaic.

 

Download latest stable version

You can get latest stable version of PDF Mosaic here.

Awaiting your questions

We're really eager to hear from you. Please send us your comments, suggestions and any other feedback via the Feedback Form.

Thank you, we really need and appreciate you help! More...

Get the Latest News

June 17 2016
We are on NuGet

June 04 2016
See tutorial about using GoTo Remote action in PDF document

May 28 2016
Read our article about using PDF Mosaic .NET SDK for generating PDF reports

Subscribe to our blog feed here:

PDF Mosaic blog feed

and you will receive notifications about new releases, sample code and how-to articles.