Mustang server API: "Ungültiger Farbraum", "Invalid color space"

76 views
Skip to first unread message

Joe Chz

unread,
Dec 3, 2023, 8:11:55 AM12/3/23
to ZUGFeRD
In German:
Hallo, 
ich habe Die Mustangserver API in meine Anwendung eingebunden.
Ich kann nun Requests schicken und erhalte ein Response.
Bei folgenden Funktionen treten jedoch Fehler auf: 

Combine PDF/A-1 file and custom XML to zf/fx PDF
Converts any PDF file into PDF/A-1

Nach dem ich eines der beiden Funktionen ausführe erhalte ich folgende Fehlermeldung beim öffnen der neu erzeugten Datei: 
"Beim Verarbeiten einer Seite ist ein Fehler aufgetreten.  Ungültiger Farbraum."
Im Anhang ist dazu ein Screenshot.
Hab es mit sowohl vorher leeren pdf Dateien probiert, als auch mit bsp. XRechnungs pdf's. 

In English:

Hello,
I have integrated the Mustangserver API into my application.
I can now send requests and receive a response.
However, errors occur with the following functions:

- Combine PDF/A-1 file and custom XML to zf/fx PDF
- Converts any PDF file into PDF/A-1

After executing one of the two functions, I receive the following error message when opening the newly created file:
"An error occurred while processing a page. Invalid color space."
There is a screenshot attached.
I tried it with both previously empty PDF files, as well as with e.g. XRechnungs pdf's.

Mein Code:










Bildschirmfoto 2023-12-03 um 14.04.47.png

Joe Chz

unread,
Dec 3, 2023, 8:18:41 AM12/3/23
to ZUGFeRD
my code:
pdftopdfa.js:
'use strict'
const gs = require("ghostscript-node");
const fs = require('fs');
const { PDFDocument, rgb, StandardFonts } = require('pdf-lib');
const pdf2json = require('pdf2json');
const pdf = require('pdfkit');
const http = require('https');
const FormData = require('form-data');
const base64 = require('base64topdf');



convertToPDFA2: async function () {

const pdf = fs.readFileSync("path input.pdf")
var username = '';
var password = '';
var auth = 'Basic ' + Buffer.from(username + ':' + password).toString('base64');

const formData = new FormData();
formData.append('file', pdf, {
filename: 'file.pdf',
contentType: 'application/pdf'
});

const options = {
hostname: 'gw.usegroup.de',
port: 8243,
path: '/mustang-doc/v1.0.0/mustang/pdf?pdfAVersion=1',
method: 'POST',
headers: {
Authorization: auth,
'Content-Type': "multipart/form-data; boundary=" + formData.getBoundary(),
}
};


const req = http.request(options, (res) => {
let data = '';


res.on('data', (chunk) => {
data += chunk;
});


res.on('end', () => {
fs.writeFileSync("path output.pdf", data);
});
});

req.on('error', (e) => {
console.error(`Problem with request: ${e.message}`);
});


formData.pipe(req);


req.end();

}
}



Message has been deleted

Joe Chz

unread,
Dec 4, 2023, 5:47:53 AM12/4/23
to ZUGFeRD
service.js:
const cds = require('');
const pdfconvert = require('')

module.exports = cds.service.impl(async function () {

const b1 = await cds.connect.to('');



this.on('sendPDF'async (req=> {


pdfconvert.convertToPDFA2()
return "finished";
});

this.on('READ''Invoice'async req => {
return b1.run(req.query);
});

this.on('READ''PaymentTerms'async req => {
return b1.run(req.query);
});

this.on('READ', ['Invoice''PaymentTerms'], req => {
return b1.run(req.query);
});

});

mustang.http:
###
Authorization: Basic {{$dotenv username}}:{{$dotenv password}}

jochen...@gmail.com

unread,
Dec 4, 2023, 12:39:46 PM12/4/23
to ZUGFeRD
Hi, 

Hello,
I have integrated the Mustangserver API into my application.
I can now send requests and receive a response.
However, errors occur with the following functions:

- Combine PDF/A-1 file and custom XML to zf/fx PDF
- Converts any PDF file into PDF/A-1

After executing one of the two functions, I receive the following error message when opening the newly created file:
"An error occurred while processing a page. Invalid color space."
There is a screenshot attached.
I tried it with both previously empty PDF files, as well as with e.g. XRechnungs pdf's.

I just tried it in the HTML client, for me it works, 
let's tackle this one by one, could you please attach a PDF file and we try to reproduce your PDF->PDF/A-1 issue first?

thanks and kind regards
Jochen
 

Joe Chz

unread,
Dec 4, 2023, 12:51:16 PM12/4/23
to ZUGFeRD
Servus,
ich habe diese leere Datei für den test benutzt (quo.pdf), um die pdf Datei in pdfA1 umzuwandeln.
Nach dem ich es ausführe, wird eine Output.pdf Datei erstellt.
Dann lade ich sie runter und öffne sie bei Adobe Acrobat Reader.
Dann erscheint beim öffnen die Fehlermeldung 
kwo.pdf

Joe Chz

unread,
Dec 4, 2023, 12:52:13 PM12/4/23
to ZUGFeRD
das ist die Output Datei 
output-13.pdf

jochen...@gmail.com

unread,
Dec 7, 2023, 7:05:28 AM12/7/23
to ZUGFeRD
Hi,
There was a similar request and I suspect the client and/or the way it's called.
Before going into too many details: can you please first try if it works on OpenAPI HTML Client, i.e. the "try out" button on the devportal?
If not, can you let me know the details, i.e. which call with which parameters and with attached files, if needed?

thanks and kind regards,
Jochen

jochen...@gmail.com

unread,
Dec 7, 2023, 7:13:10 AM12/7/23
to ZUGFeRD
Sorry, 

was struggelling with the thread view, the input needs to be a PDF/A-1 file, please convert first, i.e. use the pdf endpoint from Mustangserver-docs https://api.usegroup.de:9443/devportal/apis/f92e6108-bd37-4e87-841c-1b4e2a27e214/overview . I have logged a ticket to consider throwing an according exception. However, Mustangserver 1.1 will be released very soon and at least already support to alternatively provide a PDF/A-3 file as they can be much smaller.
kind regards
Jochen
Reply all
Reply to author
Forward
0 new messages