Skip to content

Merge pdf - getting error while viewing the pdf in acrobat reader and content is blank. #1767

@prash-copadoDemo

Description

@prash-copadoDemo

What were you trying to do?

I saw an intermittent issue, if I merge 2 pdf's I am getting an error message(attached in the screenshot) and the content is showing as blank. I noticed, it did copy the number of pages of both pdf's but the page is blank.

Appreciate any help in this regard. I am assuming it's an issue of a source file but not able to replicate by myself.

Below is the sample code I am using for merging the pdf's :-

                let tipe = this.typify(file.type);
				if (tipe == 'Pdf') {
					const fullpdf = await PDFLib.PDFDocument.load(bytes, {
						ignoreEncryption: true
					});

					var arrNumberOfPages = [];
					fullpdf.getPages().forEach((page, idx) => {
						arrNumberOfPages.push(idx);
					});
					var allpages = await pdfDoc.copyPages(fullpdf, arrNumberOfPages);
					for (var count = 0; count < allpages.length; count++) {
						let page = pdfDoc.addPage(allpages[count]);
						page.drawRectangle({
							x: 5,
							y: 5,
							width: page.getWidth() - 10,
							height: page.getHeight() - 10,
							borderColor: PDFLib.rgb(0, 0, 1),
							borderWidth: 0.5
						});
					}
				}
Image

How did you attempt to do it?

When I am trying to merge 2 pdf's I am getting the error and also it's creating the merged pdf with blank pages.

What actually happened?

Getting error and pdf's not merging properly.

Image

What did you expect to happen?

It should merge the pdf properly.

How can we reproduce the issue?

I am not able to replicate the issue by myself, it's an intermittent issue.

Version

1.7

What environment are you running pdf-lib in?

Browser

Checklist

  • My report includes a Short, Self Contained, Correct (Compilable) Example.
  • I have attached all PDFs, images, and other files needed to run my SSCCE.

Additional Notes

It might be an issue with the font, attaching the font details.

Image

Metadata

Metadata

Assignees

No one assigned

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions