Converting PDF documents to TIFF images is a very useful and basic necessity in any document management system. Whether for processing, clean up, or just change of file format for sharing, your document management application needs to be able to accomplish this task easily. Here is how to do it using GdPicture.NET.
Copy Code | |
---|---|
'We assume that GdPicture has been correctly installed and unlocked. Using oConverter As GdPictureDocumentConverter = New GdPictureDocumentConverter() Dim status As GdPictureStatus = oConverter.LoadFromFile("input.pdf", GdPicture14.DocumentFormat.DocumentFormatPDF) If status = GdPictureStatus.OK Then MessageBox.Show("The file has been loaded successfully.", "PDF to TIFF Example", MessageBoxButtons.OK, MessageBoxIcon.Information) status = oConverter.SaveAsTIFF("output.tif", TiffCompression.TiffCompressionAUTO) If status = GdPictureStatus.OK Then MessageBox.Show("The file has been saved successfully.", "PDF to TIFF Example", MessageBoxButtons.OK, MessageBoxIcon.Information) Else MessageBox.Show("The file has failed to save. Status: " + status.ToString(), "TIFF to PDF Example", MessageBoxButtons.OK, MessageBoxIcon.Error) End If Else MessageBox.Show("The file has failed to load. Status: " + status.ToString(), "TIFF to PDF Example", MessageBoxButtons.OK, MessageBoxIcon.Error) End If End Using |
Copy Code | |
---|---|
//We assume that GdPicture has been correctly installed and unlocked. using (GdPictureDocumentConverter oConverter = new GdPictureDocumentConverter()) { GdPictureStatus status = oConverter.LoadFromFile("input.pdf", GdPicture14.DocumentFormat.DocumentFormatPDF); if (status == GdPictureStatus.OK) { MessageBox.Show("The file has been loaded successfully.", "PDF to TIFF Example", MessageBoxButtons.OK, MessageBoxIcon.Information); status = oConverter.SaveAsTIFF("output.tif", TiffCompression.TiffCompressionAUTO); if (status == GdPictureStatus.OK) { MessageBox.Show("The file has been saved successfully.", "PDF to TIFF Example", MessageBoxButtons.OK, MessageBoxIcon.Information); } else { MessageBox.Show("The file has failed to save. Status: " + status.ToString(), "PDF to TIFF Example", MessageBoxButtons.OK, MessageBoxIcon.Error); } } else { MessageBox.Show("The file has failed to load. Status: " + status.ToString(), "PDF to TIFF Example", MessageBoxButtons.OK, MessageBoxIcon.Error); } } |
Copy Code | |
---|---|
'We assume that GdPicture has been correctly installed and unlocked. Dim oGdPictureImaging As New GdPictureImaging() Dim oGdPicturePDF As New GdPicturePDF() Dim multiTiffID As Integer = 0 'Loading the PDF document. Dim status As GdPictureStatus = oGdPicturePDF.LoadFromFile("input.pdf", False) 'If PDF loading was successful: If status = GdPictureStatus.OK Then 'Loop through pages. For i As Integer = 1 To oGdPicturePDF.GetPageCount() 'Selecting a page. oGdPicturePDF.SelectPage(i) 'Rendering the selected page to GdPictureImage identifier. Dim rasterizedPageID As Integer = oGdPicturePDF.RenderPageToGdPictureImageEx(200F, True) If oGdPicturePDF.GetStat() = GdPictureStatus.OK Then 'If it is the first page. If i = 1 Then multiTiffID = rasterizedPageID 'Making the image a new multipage tiff image. status = oGdPictureImaging.TiffSaveAsMultiPageFile(multiTiffID, "output.tif", TiffCompression.TiffCompressionAUTO) Else 'Adding a new image to multipage tiff image. status = oGdPictureImaging.TiffAddToMultiPageFile(multiTiffID, rasterizedPageID) 'Releasing the last image identifier. oGdPictureImaging.ReleaseGdPictureImage(rasterizedPageID) End If 'Checking for errors when adding a new page. If status <> GdPictureStatus.OK Then MessageBox.Show("TiffSaveAsMultiPageFile - Error: " + status.ToString(), "Converting PDF to TIFF Example", MessageBoxButtons.OK, MessageBoxIcon.Error) Exit For End If Else MessageBox.Show("RenderPageToGdPictureImageEx - Error: " + oGdPicturePDF.GetStat().ToString(), "Converting PDF to TIFF Example", MessageBoxButtons.OK, MessageBoxIcon.Error) Exit For End If Next 'Closing the multipage tiff file. oGdPictureImaging.TiffCloseMultiPageFile(multiTiffID) 'Releasing the multipage tiff image. oGdPictureImaging.ReleaseGdPictureImage(multiTiffID) 'Closing and releasing the PDF document. oGdPicturePDF.CloseDocument() MessageBox.Show("Done!", "Converting PDF to TIFF Example", MessageBoxButtons.OK, MessageBoxIcon.Information) Else MessageBox.Show("The PDF document can't be loaded. Status: " + status.ToString(), "Converting PDF to TIFF Example", MessageBoxButtons.OK, MessageBoxIcon.Error) End If oGdPictureImaging.Dispose() oGdPicturePDF.Dispose() |
Copy Code | |
---|---|
//We assume that GdPicture has been correctly installed and unlocked. GdPictureImaging oGdPictureImaging = new GdPictureImaging(); GdPicturePDF oGdPicturePDF = new GdPicturePDF(); int multiTiffID = 0; //Loading the PDF document. GdPictureStatus status = oGdPicturePDF.LoadFromFile("input.pdf", false); //If PDF loading was successful: if (status == GdPictureStatus.OK) { //Loop through pages. for (int i = 1; i <= oGdPicturePDF.GetPageCount(); i++) { //selecting a page. oGdPicturePDF.SelectPage(i); //Rendering the selected page to GdPictureImage identifier. int rasterizedPageID = oGdPicturePDF.RenderPageToGdPictureImageEx(200.0f, true); if (oGdPicturePDF.GetStat() == GdPictureStatus.OK) { //If it is the first page. if (i == 1) { multiTiffID = rasterizedPageID; //Making the image a new multipage tiff image. status = oGdPictureImaging.TiffSaveAsMultiPageFile(multiTiffID, "output.tif", TiffCompression.TiffCompressionAUTO); } else { //Adding a new image to multipage tiff image. status = oGdPictureImaging.TiffAddToMultiPageFile(multiTiffID, rasterizedPageID); //Releasing the last image identifier. oGdPictureImaging.ReleaseGdPictureImage(rasterizedPageID); } //Checking for errors when adding a new page. if (status != GdPictureStatus.OK) { MessageBox.Show("TiffSaveAsMultiPageFile - Error: " + status.ToString(), "Converting PDF to TIFF Example", MessageBoxButtons.OK, MessageBoxIcon.Error); break; } } else { MessageBox.Show("RenderPageToGdPictureImageEx - Error: " + oGdPicturePDF.GetStat().ToString(), "Converting PDF to TIFF Example", MessageBoxButtons.OK, MessageBoxIcon.Error); break; } } //Closing the multipage tiff file. oGdPictureImaging.TiffCloseMultiPageFile(multiTiffID); //Releasing the multipage tiff image. oGdPictureImaging.ReleaseGdPictureImage(multiTiffID); //Closing and release the PDF document. oGdPicturePDF.CloseDocument(); MessageBox.Show("Done!", "Converting PDF to TIFF Example", MessageBoxButtons.OK, MessageBoxIcon.Information); } else { MessageBox.Show("The PDF document can't be loaded. Status: " + status.ToString(), "Converting PDF to TIFF Example", MessageBoxButtons.OK, MessageBoxIcon.Error); } oGdPictureImaging.Dispose(); oGdPicturePDF.Dispose(); |