How to merge 2 PDF files
- paulo moura
- Posts: 4
- Joined: Thu Sep 06, 2007 9:12 pm
- Location: Brasil
- Contact:
How to merge 2 PDF files
Hi !
What is the best way to merge 2 PDF files with GDpicture ?
Thank you !
What is the best way to merge 2 PDF files with GDpicture ?
Thank you !
Hi,
You can only merge existing pdf creating output images content PDF mixing the gdviewer & the imaging classes of the GdPicture Pro SDK .
I give you a simple visual basic function to merge 2 pdf :
Best regards,
Loïc
You can only merge existing pdf creating output images content PDF mixing the gdviewer & the imaging classes of the GdPicture Pro SDK .
I give you a simple visual basic function to merge 2 pdf :
Code: Select all
Sub Merge2PDF(sInPDFPath1 As String, sInPDFPath2 As String, sOutPDFpath As String)
Dim nCpt As Long
Dim nPDFID As Long
Dim nImageCount As Long
Dim GdViewer1 As Object, Imaging1 As Object
Set GdViewer1 = CreateObject("gdpicturepro5.gdviewer")
Set Imaging1 = CreateObject("gdpicturepro5.imaging")
GdViewer1.SetLicenseNumber ("LICENSE KEY")
Imaging1.SetLicenseNumber ("LICENSE KEY")
Imaging1.PdfNewPdf (sOutPDFpath)
GdViewer1.LockControl = True
nImageCount = 0
GdViewer1.DisplayFromPdfFile (sInPDFPath1)
For nCpt = 1 To GdViewer1.PageCount
GdViewer1.DisplayFrame (nCpt)
If Imaging1.PdfAddImageFromGdPictureImage(GdViewer1.GetNativeImage) <> 0 Then
nImageCount = nImageCount + 1
End If
Next nCpt
GdViewer1.CloseImage
GdViewer1.DisplayFromPdfFile (sInPDFPath2)
For nCpt = 1 To GdViewer1.PageCount
GdViewer1.DisplayFrame (nCpt)
If Imaging1.PdfAddImageFromGdPictureImage(GdViewer1.GetNativeImage) <> 0 Then
nImageCount = nImageCount + 1
End If
Next nCpt
GdViewer1.CloseImage
For nCpt = 1 To nImageCount
Call Imaging1.PdfSetPageDimensions(Imaging1.PdfGetImageWidth(nCpt), Imaging1.PdfGetImageHeight(nCpt))
Imaging1.PdfNewPage
Call Imaging1.PdfDrawImage(nCpt, 0, 0, Imaging1.PdfGetImageWidth(nCpt), Imaging1.PdfGetImageHeight(nCpt))
Imaging1.PdfEndPage
Next nCpt
Imaging1.PdfSavePdf
Set GdViewer1 = Nothing
Set Imaging1 = Nothing
End Sub
Best regards,
Loïc
Re: How to merge 2 PDF files
How can I get this to work with GdPicture.NET?
Re: How to merge 2 PDF files
For GdPicture.NET see: viewtopic.php?t=1583
Re: How to merge 2 PDF files
Hello, I am having an "Out of Memory" error when I try to open the resulting file in Acrobat X. What should I be looking at?
I work in PowerBuilder11.5 and this is my code:
//------------------------------------------
inv_imaging.PdfNewPdf (as_dst_pdf, "Title", "Creator", "Author", "Producer")
inv_imaging.PdfSetMeasurementUnits(2)
ll_font = inv_imaging.PdfAddFont("Arial")
ll_image = inv_imaging.PdfAddImageFromFile(as_pic_file)
ll_width = inv_imaging.PdfGetImageWidth(ll_image)
ll_height = inv_imaging.PdfGetImageHeight(ll_image)
inv_imaging.PdfSetPageDimensions(ll_width + 5, ll_height + 5)
rc = inv_imaging.PdfNewPage()
inv_imaging.PdfDrawText(5, 10, "Arial Text Size 7", ll_font, 7)
inv_imaging.PdfDrawImage(ll_image, 1, 1, ll_width, ll_height)
inv_imaging.PdfEndPage()
inv_imaging.PdfSavePdf()
//----------------------------------------
I work in PowerBuilder11.5 and this is my code:
//------------------------------------------
inv_imaging.PdfNewPdf (as_dst_pdf, "Title", "Creator", "Author", "Producer")
inv_imaging.PdfSetMeasurementUnits(2)
ll_font = inv_imaging.PdfAddFont("Arial")
ll_image = inv_imaging.PdfAddImageFromFile(as_pic_file)
ll_width = inv_imaging.PdfGetImageWidth(ll_image)
ll_height = inv_imaging.PdfGetImageHeight(ll_image)
inv_imaging.PdfSetPageDimensions(ll_width + 5, ll_height + 5)
rc = inv_imaging.PdfNewPage()
inv_imaging.PdfDrawText(5, 10, "Arial Text Size 7", ll_font, 7)
inv_imaging.PdfDrawImage(ll_image, 1, 1, ll_width, ll_height)
inv_imaging.PdfEndPage()
inv_imaging.PdfSavePdf()
//----------------------------------------
Re: How to merge 2 PDF files
Actually, now I am getting the same problem when trying to use it with c#:
//--------------------------------------
using System;
using System.Collections.Generic;
using System.Text;
using System.Xml;
using System.Security;
namespace ConsoleApplication1
{
class Program
{
static void Main(string[] args)
{
string ls_src_pdf, ls_dst_pdf, ls_src_pic, ls_args;
int ll_image;
XmlDocument ls_xml = new XmlDocument();
ls_args = "<Root><SourcePDF></SourcePDF><SourcePic>.\\test.jpg</SourcePic>";
ls_args += "<DestPDF>.\\reg_card_78582_1_signed.pdf</DestPDF></Root>";
ls_xml.InnerXml = ls_args;
ls_src_pdf = ls_xml.DocumentElement.ChildNodes[0].InnerText;
ls_src_pic = ls_xml.DocumentElement.ChildNodes[1].InnerText;
ls_dst_pdf = ls_xml.DocumentElement.ChildNodes[2].InnerText;
GdPicturePro5.cImaging ln_imaging = new GdPicturePro5.cImaging();
ln_imaging.SetLicenseNumber("XXXXXX");
ln_imaging.PdfNewPdf(ls_dst_pdf);
ll_image = ln_imaging.PdfAddImageFromFile(ls_src_pic);
ln_imaging.PdfSetMeasurementUnits(1);
ln_imaging.PdfNewPage();
ln_imaging.PdfSetPageDimensions(200, 150);
if (ll_image != 0)
{
ln_imaging.PdfDrawImage(ll_image, 100, 100, 30, 25);
}
ln_imaging.PdfEndPage();
ln_imaging.PdfSavePdf();
}
}
}
//--------------------------------------
//--------------------------------------
using System;
using System.Collections.Generic;
using System.Text;
using System.Xml;
using System.Security;
namespace ConsoleApplication1
{
class Program
{
static void Main(string[] args)
{
string ls_src_pdf, ls_dst_pdf, ls_src_pic, ls_args;
int ll_image;
XmlDocument ls_xml = new XmlDocument();
ls_args = "<Root><SourcePDF></SourcePDF><SourcePic>.\\test.jpg</SourcePic>";
ls_args += "<DestPDF>.\\reg_card_78582_1_signed.pdf</DestPDF></Root>";
ls_xml.InnerXml = ls_args;
ls_src_pdf = ls_xml.DocumentElement.ChildNodes[0].InnerText;
ls_src_pic = ls_xml.DocumentElement.ChildNodes[1].InnerText;
ls_dst_pdf = ls_xml.DocumentElement.ChildNodes[2].InnerText;
GdPicturePro5.cImaging ln_imaging = new GdPicturePro5.cImaging();
ln_imaging.SetLicenseNumber("XXXXXX");
ln_imaging.PdfNewPdf(ls_dst_pdf);
ll_image = ln_imaging.PdfAddImageFromFile(ls_src_pic);
ln_imaging.PdfSetMeasurementUnits(1);
ln_imaging.PdfNewPage();
ln_imaging.PdfSetPageDimensions(200, 150);
if (ll_image != 0)
{
ln_imaging.PdfDrawImage(ll_image, 100, 100, 30, 25);
}
ln_imaging.PdfEndPage();
ln_imaging.PdfSavePdf();
}
}
}
//--------------------------------------
Re: How to merge 2 PDF files
Hi,
Please find the merge PDF functionality of the GdPicture14 here:
https://www.gdpicture.com/guides/gdpicture/web ... ments.html
https://www.gdpicture.com/guides/gdpicture/web ... ments.html
Please find the merge PDF functionality of the GdPicture14 here:
https://www.gdpicture.com/guides/gdpicture/web ... ments.html
https://www.gdpicture.com/guides/gdpicture/web ... ments.html
Re: How to merge 2 PDF files
Thanks Gabriela, for this valuable reply.Helpful
Re: How to merge 2 PDF files
You're welcome!
We are always happy to hear that.
We are always happy to hear that.
Re:
Loïc wrote: ↑Fri Nov 30, 2007 12:56 pmHi,
You can only merge existing pdf creating output images content PDF mixing the gdviewer & the imaging classes of the GdPicture Pro SDK .
I give you a simple visual basic function to merge 2 pdf :
Code: Select all
Sub Merge2PDF(sInPDFPath1 As String, sInPDFPath2 As String, sOutPDFpath As String) Dim nCpt As Long Dim nPDFID As Long Dim nImageCount As Long Dim GdViewer1 As Object, Imaging1 As Object Set GdViewer1 = CreateObject("gdpicturepro5.gdviewer") Set Imaging1 = CreateObject("gdpicturepro5.imaging") GdViewer1.SetLicenseNumber ("LICENSE KEY") Imaging1.SetLicenseNumber ("LICENSE KEY") Imaging1.PdfNewPdf (sOutPDFpath) GdViewer1.LockControl = True nImageCount = 0 GdViewer1.DisplayFromPdfFile (sInPDFPath1) For nCpt = 1 To GdViewer1.PageCount GdViewer1.DisplayFrame (nCpt) If Imaging1.PdfAddImageFromGdPictureImage(GdViewer1.GetNativeImage) <> 0 Then nImageCount = nImageCount + 1 End If Next nCpt GdViewer1.CloseImage GdViewer1.DisplayFromPdfFile (sInPDFPath2) For nCpt = 1 To GdViewer1.PageCount GdViewer1.DisplayFrame (nCpt) If Imaging1.PdfAddImageFromGdPictureImage(GdViewer1.GetNativeImage) <> 0 Then nImageCount = nImageCount + 1 End If Next nCpt GdViewer1.CloseImage For nCpt = 1 To nImageCount Call Imaging1.PdfSetPageDimensions(Imaging1.PdfGetImageWidth(nCpt), Imaging1.PdfGetImageHeight(nCpt)) Imaging1.PdfNewPage Call Imaging1.PdfDrawImage(nCpt, 0, 0, Imaging1.PdfGetImageWidth(nCpt), Imaging1.PdfGetImageHeight(nCpt)) Imaging1.PdfEndPage Next nCpt Imaging1.PdfSavePdf Set GdViewer1 = Nothing Set Imaging1 = Nothing End Sub
Best regards,
Loïc
Thanks for this code. It worked for me. I was stuck for long time, it helped me out t complete my project.
Who is online
Users browsing this forum: No registered users and 1 guest