docfx: PDF Build fails in Azure DevOps
Operation System: Windows
DocFX Version Used: DocFx Build Tasks - Visual Studio Marketplace Extension
Template used: pdf.default
Additional Information: I am able to create the PDF locally just not in a build pipeline in Azure DevOps.
Steps to Reproduce:
- Get Sources from repository
- Add Chocolatey task to Install wkhtmltopdf
- Run Create DocFx task to create PDF
- Project File “docfx_pdf.json” <-- Just testing PDF build. Content builds work correctly.
"pdf": {
"content": [
{
"files": [
"**/*.md",
"**/**.yml"
],
"exclude": [
"**/toc.yml",
"**/toc.md"
]
},
{
"files": "pdf/toc.yml"
}
],
"resource": [
{
"files": [
"**/*.png",
"**/*.jpg",
"**/*.gif",
"**/*.pdf",
"**/*.pptx",
"favicon.ico"
],
"exclude": [
"**/obj/**",
"**/includes/**",
"**/_site_pdf/**"
]
}
],
"overwrite": [],
"dest": "_site_pdf"
}
Expected Behavior: Create PDF file
Actual Behavior: PDF file is not create with these errors in the Build Pipeline.
[19-05-06 06:59:08.197]Error:[PdfCommand.PDF]Error happen when converting pdf/toc.json to Pdf. Details: System.InvalidOperationException: The file is not a valid PDF document.
at PdfSharp.Pdf.IO.PdfReader.Open(Stream stream, String password, PdfDocumentOpenMode openmode, PdfPasswordProvider passwordProvider)
at Microsoft.DocAsCode.HtmlToPdf.HtmlToPdfConverter.SaveCore(Stream stream)
at Microsoft.DocAsCode.HtmlToPdf.HtmlToPdfConverter.Save(String outputFileName)
at Microsoft.DocAsCode.HtmlToPdf.ConvertWrapper.<>c__DisplayClass7_0.<ConvertCore>b__1(ManifestItem tocFile)
24 Warning(s)
1 Error(s)
##[error]Unable to run command: d:\a\1\s\docfx_pdf.json
code: 1
[19-05-06 06:58:57.112]Info:[PdfCommand.BuildCore.Build Document.LinkPhaseHandlerWithIncremental.Apply Templates]Applying templates to 1029 model(s)...
[19-05-06 06:58:57.707]Info:[PdfCommand.BuildCore.Build Document]XRef map exported.
[19-05-06 06:58:58.568]Info:[PdfCommand.Postprocess]Manifest file saved to manifest.json.
[19-05-06 06:58:58.661]Info:[PdfCommand]Completed building documents in 7219.7605 milliseconds.
[19-05-06 06:58:58.661]Info:[PdfCommand.PDF]Start generating PDF files...
[19-05-06 06:59:08.009]Error:[PdfCommand.PDF]Error happen when converting pdf/toc.json to Pdf. Details: System.InvalidOperationException: The file is not a valid PDF document.
at PdfSharp.Pdf.IO.PdfReader.Open(Stream stream, String password, PdfDocumentOpenMode openmode, PdfPasswordProvider passwordProvider)
at Microsoft.DocAsCode.HtmlToPdf.HtmlToPdfConverter.SaveCore(Stream stream)
at Microsoft.DocAsCode.HtmlToPdf.HtmlToPdfConverter.Save(String outputFileName)
at Microsoft.DocAsCode.HtmlToPdf.ConvertWrapper.<>c__DisplayClass7_0.<ConvertCore>b__1(ManifestItem tocFile)
[19-05-06 06:59:08.197]Info:[PdfCommand.PDF]Completed Scope:PdfCommand.PDF in 9530.6019 milliseconds.
[19-05-06 06:59:08.197]Info:[PdfCommand]Completed Scope:PdfCommand in 17068.4582 milliseconds.
[19-05-06 06:59:08.197]Info:Completed in 17073.8428 milliseconds
Build failed.
[19-05-06 06:59:08.197]Error:[PdfCommand.PDF]Error happen when converting pdf/toc.json to Pdf. Details: System.InvalidOperationException: The file is not a valid PDF document.
at PdfSharp.Pdf.IO.PdfReader.Open(Stream stream, String password, PdfDocumentOpenMode openmode, PdfPasswordProvider passwordProvider)
at Microsoft.DocAsCode.HtmlToPdf.HtmlToPdfConverter.SaveCore(Stream stream)
at Microsoft.DocAsCode.HtmlToPdf.HtmlToPdfConverter.Save(String outputFileName)
at Microsoft.DocAsCode.HtmlToPdf.ConvertWrapper.<>c__DisplayClass7_0.<ConvertCore>b__1(ManifestItem tocFile)
24 Warning(s)
1 Error(s)
stderr: QFont::setPixelSize: Pixel size <= 0 (0)
error: undefined
About this issue
- Original URL
- State: closed
- Created 5 years ago
- Comments: 19 (14 by maintainers)
Commits related to this issue
- adding NoInputStreamArgs option #4488 — committed to oleksabor/docfx by deleted user 5 years ago
- config option name changed to noStdin #4488 — committed to oleksabor/docfx by deleted user 5 years ago
- new pdf option noStdin (#4719) * adding NoInputStreamArgs option #4488 * config option name changed to noStdin #4488 * tabs were replaced with spaces * tabs were replaced with spaces * no... — committed to dotnet/docfx by oleksabor 5 years ago
- Avoid nostdin https://github.com/dotnet/docfx/issues/4488 https://github.com/wkhtmltopdf/wkhtmltopdf/issues/4450 — committed to QutEcoacoustics/audio-analysis by atruskie 3 years ago
- Docs generation is now automatic Docs get built and published (to netlify) on commit. Also builds docs as a downloadable PDF. This is a combination of 6 commits. add first github actions workflow ... — committed to QutEcoacoustics/audio-analysis by atruskie 3 years ago
- Temporarily disabled API docs It is causing pdf generation to fail. See https://github.com/dotnet/docfx/issues/4488#issuecomment-567859485 — committed to QutEcoacoustics/audio-analysis by atruskie 3 years ago
The workaround (add
"noStdin" : trueto docfx.json) to fix this issue that was added here https://github.com/dotnet/docfx/pull/4719 does not work for me. I now get the following error:Is there a way to reduce the list of arguments passed?
Looks nothing wrong within the TOC.
I can only see some error happened when the PDF processing library tries opening the intermediate PDF. You could try add
"keepRawFiles": truein config to see is there something wrong in the intermediate files generated.I used Chocolatey task to install DocFx v2.41.0 prior to running the DocFx Build Tasks. It looks like v2.41.0 of DocFx gives warnings that there was an error, which allows the pipeline to finish but the PDF comes out as 0 bytes.
Instead of the previous error, I now receive:
2019-05-08T19:04:34.7537835Z [19-05-08 07:04:34.515]Warning:[PdfCommand.PDF]Error happen when converting pdf/toc.json to Pdf. Details: One or more errors occurred.